package cn.com.haopy.yue.ai.db.service.hos.impl;

import cn.com.haopy.yue.ai.db.entity.arisk.AIRiskIllnessCheckIndex;
import cn.com.haopy.yue.ai.db.mapper.arisk.AIRiskIllnessCheckIndexMapper;
import cn.com.haopy.yue.ai.db.service.BaseServiceImpl;
import cn.com.haopy.yue.ai.db.service.hos.AIRiskIllnessCheckIndexService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: TODO
 * @Author DuTao
 * @Date 2025/3/28 16:57
 */
@Service
public class AIRiskIllnessCheckIndexServiceImpl extends BaseServiceImpl<AIRiskIllnessCheckIndexMapper, AIRiskIllnessCheckIndex> implements AIRiskIllnessCheckIndexService {
    @Autowired
    private AIRiskIllnessCheckIndexMapper mapper;

    @Override
    public boolean deleteByIllnessId(Integer illnessId) {
        LambdaQueryWrapper<AIRiskIllnessCheckIndex> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AIRiskIllnessCheckIndex::getIllnessId, illnessId);
        return super.remove(queryWrapper);
    }

    @Override
    public List<AIRiskIllnessCheckIndex> getByIllnessId(Integer illnessId) {
        LambdaQueryWrapper<AIRiskIllnessCheckIndex> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AIRiskIllnessCheckIndex::getIllnessId, illnessId);
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public AIRiskIllnessCheckIndex getByCondition(Integer illnessId, Integer indexId) {
        LambdaQueryWrapper<AIRiskIllnessCheckIndex> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AIRiskIllnessCheckIndex::getIllnessId, illnessId);
        queryWrapper.eq(AIRiskIllnessCheckIndex::getIndexId, indexId);
        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public List<Integer> getAllDelete(Integer illnessId) {
        List<Integer> result = null;
        LambdaQueryWrapper<AIRiskIllnessCheckIndex> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AIRiskIllnessCheckIndex::getIllnessId, illnessId);
        queryWrapper.eq(AIRiskIllnessCheckIndex::getDeleted, 1);
        for (AIRiskIllnessCheckIndex aiRiskIllnessCheckIndex : baseMapper.selectList(queryWrapper)) {
            result.add(aiRiskIllnessCheckIndex.getIndexId());
        }
        return result;
    }

    @Override
    public AIRiskIllnessCheckIndex getByIllnessIdAndIndexId(Integer illnessId, Integer indexId) {
        return mapper.getByIllnessIdAndIndexId(illnessId, indexId);
    }

    @Override
    public List<AIRiskIllnessCheckIndex> getAll(Integer illnessId) {
        LambdaQueryWrapper<AIRiskIllnessCheckIndex> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AIRiskIllnessCheckIndex::getIllnessId, illnessId);
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public List<AIRiskIllnessCheckIndex> getDeleteAll(Integer illnessId) {
        return mapper.getDeleteList(illnessId);
    }

    @Override
    public Integer updateDelete(AIRiskIllnessCheckIndex checkIndexEntity) {
        return mapper.updateDelete(checkIndexEntity.getUpdateBy(), checkIndexEntity.getDeleted(),checkIndexEntity.getId());
    }

    @Override
    public boolean deleteByIllnessIdAndIndexId(Integer illnessId, Integer indexId) {
        LambdaQueryWrapper<AIRiskIllnessCheckIndex> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AIRiskIllnessCheckIndex::getIllnessId, illnessId);
        queryWrapper.eq(AIRiskIllnessCheckIndex::getIndexId, indexId);
        return super.remove(queryWrapper);
    }

    @Override
    public List<AIRiskIllnessCheckIndex> getByIndexId(Integer indexId) {
        LambdaQueryWrapper<AIRiskIllnessCheckIndex> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AIRiskIllnessCheckIndex::getIndexId, indexId);
        return baseMapper.selectList(queryWrapper);
    }
}
